import { MemoryManager } from "GameLoop/DecisionMaking/MemoryManager";
import { ABaseEntity } from "GameLoop/WorldState/EntityManager/Entitys/BaseEntity";
import { AllEntityTypes, EntityType, ExucuteType, IEntity } from "GameLoop/WorldState/EntityManager/Entitys/Entity.interface";

 
 
/**
 * 房间位置拓展
 */
export default class EntityExtension extends Room implements IEntity<RoomMemory>
{
   
   GUID()
   {
      return this.name
   }
   initAttributes():void
   {
       MemoryManager.allocHeap(this.GUID());
       (this as any)._cacheCreep={}
   }
   getEntityByID<T extends ABaseEntity<INoMemory>>(id: string): T 
   {
      return global.entityDB.getEntityByID<T>(id);         
   }
   getEntity<T extends EntityType>(type: T, region: string=this.name): AllEntityTypes[T] {
      return global.entityDB.getEntity<T>(type,region);    
   }
   getEntitys<T extends EntityType>(type: T, region: string=this.name): AllEntityTypes[T][] {
      return global.entityDB.getEntitys<T>(type,region);    
   }
   getNodeMemory(): RoomMemory {
      return this.memory 
   }
   removeEntityByID(id: string): boolean {
    return global.entityDB.removeEntityByID(id);
    }
   entityType(): ExucuteType {
      return "Room"
   }
   public getNodeHeap<T extends any>(): T{
      
      return MemoryManager.getHeap(this.GUID());
   }
   public log(type:LogType,...arg:[]):void
   {
       global.Log.Text(this.GUID(),arg.join("\t"),type);
   }
   
   
}